<template>
  <el-container>
    <!-- <el-header>
       <el-button @click="$router.push('/foodSafety/archives/archives')"    style="margin-right: 20px" icon="el-icon-back" type="primary"
            >返回上一页</el-button
          >
          <rz-height></rz-height>
      <div class="title">
        {{data.operAtorName||data.unitname}}
      </div>
      <rz-height></rz-height>
      <el-row :gutter="20">
        <el-col :span="6">统一社会信用代码:{{data.identify}}</el-col>
        <el-col :span="6" v-if="data.newlicenseno">许可证编号:{{data.newlicenseno}}</el-col>
      </el-row>
      <rz-height></rz-height>
      <el-row>
        <el-col :span="24">地址:{{data.productionAddress||data.address}}</el-col>
      </el-row>
    </el-header>
     <el-header> -->

         <div class="Jump">
       <el-button
        @click="Jump"
        style="margin-right: 20px"
        icon="el-icon-back"
        type="primary"
        >返回上一页</el-button
      >
    </div>
    <el-header>
      <rz-height></rz-height>
      <div class="title_wapper">
        <!-- <el-progress :width="100" :stroke-width="12" color="#fff" type="circle" :format="()=>data.indexScore||0" :percentage="data.indexScore||0"></el-progress> -->
        <div class="title_right">
          <div class="title">
            {{ data.workStationName }}
          </div>
      <rz-height></rz-height>
           <div style="display:flex;align-items: center;">
              <el-tag>{{ data.districtName + "—" + data.streetName }}</el-tag>
               <div>食安站站长：{{ data.userName }}({{ data.userTelTrue }})</div>
           </div>
           
        </div>
      </div>

      <!--  -->

      <rz-height></rz-height>
      <el-row :gutter="20">
        <el-col :span="8">统一社会信用代码：{{ data.identify }}</el-col>
        <el-col :span="12"
          >营业执照名称：{{ data.unitName }}
          
          </el-col
        >
      </el-row>
      <!-- <rz-height></rz-height> -->

      <!-- <el-row :gutter="20">
        <el-col :span="8" v-if="data.newlicenseno">许可证编号：{{ data.newlicenseno }}</el-col>
        <el-col :span="12">经营者名称：{{data.operAtorName}}</el-col>
      </el-row> -->
      <rz-height></rz-height>
      <rz-height></rz-height>
      <el-row :gutter="20">
        <el-col :span="8">注册日期：{{ data.createDateTimeStr }}</el-col>
        <el-col :span="12"
          >地址：{{ data.productionAddress || data.address }}</el-col
        >
      </el-row>
         <div class="qr_code">
        <vue-qr
          :text="url"
          ref="Qrcode"
          :margin="0"
          :logoScale="0.3"
          :size="90"
        ></vue-qr>

        <el-button @click="getQrCode()" size="mini" style="margin-top:10px">下载食安码</el-button>
      </div>
    </el-header>
    <el-container class="content">
      <el-aside width="200px">
        <el-menu
          :default-active="defaultActive"
          class="el-menu-vertical-demo"
          router
        >
          <el-menu-item
            :index="`${item.route}`"
            v-for="item in list"
            :key="item.id"
          >
            <span slot="title">{{ item.title }}</span>
          </el-menu-item>
          <!-- <el-menu-item index="2">
            <span slot="title">安全事故</span>
          </el-menu-item> -->
          <!-- <el-menu-item index="2">
            <span slot="title">主体责任</span>
          </el-menu-item>
          <el-menu-item index="2">
            <span slot="title">投诉举报</span>
          </el-menu-item>
          <el-menu-item index="2">
            <span slot="title">监督执法</span>
          </el-menu-item>
          <el-menu-item index="2">
            <span slot="title">食品抽检</span>
          </el-menu-item> -->
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>
<script>
import { findWorkstation } from "@/api/modules/workstation";
import vueQr from "vue-qr";
export default {
    components: {
    vueQr,
  },
  // props:[],
  // 页面加载
  created() {
      this.code = this.$route.query.url || false;
         if(this.$route.query.route){
        this.defaultActive=this.$route.query.route
   }
    this.getCompanyMainPageInfo();
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {},
  //实例销毁后
  destroyed() {},
  data() {
    return {
       url: `https://spaq.suzhou.gov.cn/ssa-publicity/#/workstation?id=${sessionStorage.getItem(
        "workId"
      )}`,
      list: [
        {
          title: "综合分析",
          id: 10,
          route: "/workstationScore/analysis",
        },
        {
          title: "经营单位",
          id: 0,
          route: "/workstation/businessUnit",
        },
        {
          title: "工作站制度",
          id: 1,
          route: "/workstation/system",
        },
        {
          title: "联席会议",
          id: 2,
          route: "/workstation/meeting",
        },
        {
          title: "组织培训",
          id: 3,
          route: "/workstation/trainingRecord",
        },
        {
          title: "检查台账",
          id: 4,
          route: "/workstation/checkAccount",
        },
        {
          title: "定期互查",
          id: 5,
          route: "/workstation/regularInspection",
        },
        {
          title: "食安快检",
          id: 6,
          route: "/workstation/quickInspection",
        },
        {
          title: "成员架构",
          id: 7,
          route: "/workstation/member",
        },
        {
          title: "投诉处理",
          id: 8,
          route: "/workstation/complaint",
        },
        {
          title: "宣传公示",
          id: 9,
          route: "/workstation/publicity",
        },
      ],
      defaultActive: "/workstationScore/analysis",
      data: {},
       code: false,
    };
  },
  // 方法
  methods: {
    getCompanyMainPageInfo() {
      findWorkstation({
        params: {
          id: sessionStorage.getItem("workId"),
        },
      }).then((res) => {
        sessionStorage.setItem("unitName",res.data.unitName)
        this.data = res.data;
      });
    },
      format(){
      return 
    },
   Jump() {
        this.$router.replace(this.code);
    },
      getQrCode() {
      const iconUrl = this.$refs.Qrcode.$el.src;
      // console.log(iconUrl);
      // this.$downloadFiles(iconUrl);

      const a = document.createElement("a");
      const event = new MouseEvent("click");
      a.download = "食安码" + new Date().getTime(); //下载后文件名
      a.href = iconUrl;
      a.dispatchEvent(event);
    },
  },
  // 监听属性
  watch: {},
  // 组件
  // 计算属性
  computed: {
  
  },
};
</script>

<style lang="scss" scoped>
.el-container {
  height: calc(100% - 130px);

  .el-header {
    padding: 20px;
    height: auto !important;
      background: $default;
    color: #ffffff;
       // background-image: linear-gradient(to right, #72BBFF , #1D92FF);
    .title_wapper {
      display: flex;
      .title {
        font-size: 25px;
        font-weight: 700;
      }

      .el-tag {
        margin-right: 10px;
      }
      .title_right{
        display: flex;
        justify-content: space-between;
        flex-direction: column;
     
      }
      /deep/ .el-progress__text{
        font-size: 18px !important;
        color: #FFFF;
      }
    }
     .qr_code {
      position: absolute;
      right: 20%;
      top: 10%;
      display: flex;
      flex-direction: column;
    }
  }
 .Jump {
    padding: 10px;
    background: #2e40d1;
  }
  .el-aside {
    height: 100%!important;
    /deep/ .el-menu {
      border-right: none;
    }
  }

  .el-main {
    background-color: #f2f2f2;
    // height: 100%;
  }
}
// .content{
//   height:calc(100% - 120px);
// }
</style>